package com.epcs.model.dao;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;

import com.epcs.model.dto.Role;
import com.epcs.util.DBUtil;

public class RoleDAO {

	public Role getRoleByName(String roleName) {

		Session session = DBUtil.getSession();
		try {
			Criteria criteria = session.createCriteria(Role.class);
			criteria.add(Restrictions.like("roleName", roleName));
			Role role = (Role) criteria.uniqueResult();
			if (role != null) {
				return role;
			}
		} finally {
			if (session != null) {
				session.close();
			}
		}

		return null;
	}
	
}
